

import 'package:flutter/cupertino.dart';
import 'package:card_swiper/card_swiper.dart';
class SwiperWidget extends StatefulWidget {
  const SwiperWidget({Key? key}) : super(key: key);

  @override
  State<SwiperWidget> createState() => _SwiperWidgetState();
}

class _SwiperWidgetState extends State<SwiperWidget> {
  final List<Image> imagesSwiper = [
    Image.asset("assets/B1.jpg",fit: BoxFit.fill),
    Image.asset("assets/B2.jpg",fit: BoxFit.fill),
    Image.asset("assets/B3.jpg",fit: BoxFit.fill),
    Image.asset("assets/B4.jpg",fit: BoxFit.fill),
    Image.asset("assets/B5.jpg",fit: BoxFit.fill),
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 180,
      padding: EdgeInsets.all(5),
      child: Swiper(
        key: UniqueKey(), // 必须添加 代表唯一 
        itemCount: imagesSwiper.length,
        autoplay: true,
        itemBuilder:(BuildContext context,int index){
            return Container(
              child: imagesSwiper[index],
              padding: EdgeInsets.all(5),
            );
        },
        //pagination: SwiperPagination(),
        viewportFraction: 0.95,
        control: SwiperControl(),
      ),
    );
    
  }
}